package binary_tree

import (
	"math/rand"
	"time"
)

func GenerateBT(level, maxLevel, maxInt int) *Node {
	rand.Seed(time.Now().UnixNano())
	time.Sleep(time.Nanosecond)
	if level > maxLevel || rand.Intn(10) < 4 {
		return nil
	}
	node := &Node{Val: rand.Intn(maxInt+1)}
	node.Left = GenerateBT(level+1, maxLevel, maxInt)
	node.Right = GenerateBT(level+1, maxLevel, maxInt)
	return node
}
